/*
 * Copyright (c) 2017 Qunar.com. All Rights Reserved.
 */
package com.guoyu.project.common.pagination;

import java.io.Serializable;
import java.util.List;

/**
 * @author: libo Date: 17-2-7 Time: 下午4:11
 * @version: \$Id$
 */
public class Pagination<T> implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 7200013490492481338L;

    /**
     * sql分页查询数据，记录开始位置
     */
    public static final String OFFSET = "offset";
    /**
     * sql分页查询一次查询记录数
     */
    public static final String LIMIT = "limit";

    /**
     * 开始位置
     */
    private int offset;
    /**
     * 每页数据量
     */
    private int limit;
    /**
     * 总数
     */
    private int total;
    /**
     * 获取该页的数据列表
     */
    protected List<T> rows;

    public Pagination(int offset, int limit) {
        this.offset = offset;
        this.limit = limit;
    }

    public Pagination(int offset, int limit, int total, List<T> rows) {
        this.offset = offset;
        this.limit = limit;
        this.total = total;
        this.rows = rows;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public int getTotal() {
        return total;
    }

    public Pagination<T> setTotal(int total) {
        this.total = total;
        return this;
    }

    public List<T> getRows() {
        return rows;
    }

    public Pagination<T> setRows(List<T> rows) {
        this.rows = rows;
        return this;
    }
}
